/**
 * CS543 HW4 Joseph Meyer
 */
package edu.src.address;

/**
 * Records the 'dirty bit'
 * <p>
 * We can reduce this overhead by using a modify bit (or dirty bit). When<br>
	this scheme is used, each page or frame has a modify bit associated with it in<br>
	the hardware. The modify bit for a page is set by the hardware whenever any<br>
	byte in the page is written into, indicating that the page has been modified.<br>
	When we select a page for replacement, we examine its modify bit. If the bit<br>
	is set, we know that the page has been modified since it was read in from the<br>
	disk. In this case, we must write the page to the disk. If the modify bit is not set,<br>
	however, the page has not been modified since it was read into memory. In this<br>
	case, we need not write the memory page to the disk: it is already there. This<br>
	technique also applies to read-only pages (for example, pages of binary code).<br>
 * -pg 411<br>
 * 
 * @author meyer
 */
public enum ReadWriteBit {
	READ,
	WRITE,
	NONE;
	
	/**
	 * Return the enum, given a matching string.
	 * @param bit - "Read" "R" "Write" "W" (or any case that matches
	 * @return READ, WRITE or NONE
	 */
	public static ReadWriteBit parse (String bit) {
		
		if (bit.equalsIgnoreCase("read") || (bit.equalsIgnoreCase("r"))) {
			return READ;
		} else if (bit.equalsIgnoreCase("write") || (bit.equalsIgnoreCase("w"))) {
			return WRITE;
		} 
		return NONE;
	}
}
